package pers.zb.center.web.boss.controller.fileprint.template.method;

import freemarker.template.SimpleScalar;
import freemarker.template.TemplateMethodModel;
import freemarker.template.TemplateModelException;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;
import pers.zb.center.web.boss.controller.fileprint.util.CommonUtils;

import java.util.List;

@SuppressWarnings("deprecation")
@Component("moneyMethod")
public class MoneyMethod implements TemplateMethodModel {

    @SuppressWarnings("rawtypes")
    public Object exec(List arguments) throws TemplateModelException {
        if (arguments != null && !arguments.isEmpty() && arguments.get(0) != null && StringUtils.isNotEmpty(arguments.get(0).toString())) {
            String code = arguments.get(0).toString();
            return new SimpleScalar(CommonUtils.money(Long.parseLong(code)));
        }
        return null;
    }

}